//Copyright 2011 - Jonathan Allen

using System;
using System.Windows.Data;
using System.Globalization;
using System.Diagnostics.Contracts;

namespace Granite.Xaml.Converters
{
	/// <summary>
	/// Returns True if the value is not null, otherwise returns false
	/// </summary>
	[ValueConversion(typeof(object), typeof(bool))]
	public class NotNullToTrueConverter : OneWayMarkupValueConverter<NotNullToTrueConverter>
	{

		/// <summary>
		/// 
		/// </summary>
		/// <param name="value"></param>
		/// <param name="targetType">Boolean</param>
		/// <param name="parameter"></param>
		/// <param name="culture"></param>
		/// <returns>True if the value is not null, oterhwise returns false</returns>
        [Pure]
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			CheckTargetType(targetType, typeof(bool), typeof(bool?));

			return value != null;
		}

	}
}
